package cc.zy.base.hr.service.impl;

import cc.zy.base.common.entity.QueryRequest;
import cc.zy.base.hr.entity.HrDeptSynLog;
import cc.zy.base.hr.mapper.HrDeptSynLogMapper;
import cc.zy.base.hr.service.IHrDeptSynLogService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author cheng
 * @time 2022/03/10 13:54:16
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class HrDeptSynLogServiceImpl extends ServiceImpl<HrDeptSynLogMapper, HrDeptSynLog> implements IHrDeptSynLogService {

    @Autowired
    private HrDeptSynLogMapper logMapper;

    /**
     * 日志
     * @param hrDeptSynLog
     */
    @Override
    public void createDrDeptSynLog(HrDeptSynLog hrDeptSynLog) {
        logMapper.createHrDeptSynLog(hrDeptSynLog);
    }

    /**
     * 日志分页
     * @param request QueryRequest
     * @param hrDeptSynLog hrDeptSynLog
     * @return
     */
    @Override
    public IPage<HrDeptSynLog> getDrDeptSynLogs(QueryRequest request, HrDeptSynLog hrDeptSynLog) {
        Page<HrDeptSynLog> page = new Page<>(request.getPageNum(), request.getPageSize());
        page.setSearchCount(false);
        page.setTotal(baseMapper.countHrDeptSynLogDetail(hrDeptSynLog));
        return baseMapper.getHrDeptSynLogDetailPage(page, hrDeptSynLog);
    }
}
